//2009/08/14 04:17:41
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class bloggoShortcuts
{
public:
    string expand(string text)
    {
        bool flag1 = true;
        bool flag2 = true;
        string s;
        for (int i=0; i<text.size(); i++)
        {
            if (text[i] == '*')
            {
                if (flag1) s += "<b>";
                else s += "</b>";
                flag1 ^= true;
            }
            else if (text[i] == '_')
            {
                if (flag2) s += "<i>";
                else s += "</i>";
                flag2 ^= true;
            }
            else s += text[i];
        }
        return s;
    }
};
